package com.yzc.android.ui.adapter;

import android.support.annotation.LayoutRes;
import android.view.View;

import java.util.List;

import com.marshalchen.ultimaterecyclerview.UltimateRecyclerviewViewHolder;
import com.yzc.android.R;
import com.yzc.android.ui.viewholder.HeaderViewHolder;
import com.yzc.android.ui.viewholder.ItemViewHolder;
import com.yzc.android.ui.viewholder.KDBaseViewHolder;

/**
 * Created by yzc on 16/4/20.
 */
public class RecyclerViewAdapter extends KDRecyclerViewBaseAdapter<String, UltimateRecyclerviewViewHolder> {

    public RecyclerViewAdapter(final List<String> list) {
        super(list);
    }

    @Override
    protected UltimateRecyclerviewViewHolder createCustomViewHolder(final View view, final int viewTypes) {
        switch (viewTypes)
        {
            case VIEW_TYPES.NORMAL:
            {
                return new ItemViewHolder(view);
            }
            case VIEW_TYPES.HEADER:
            {
                return new HeaderViewHolder(view);
            }
            case VIEW_TYPES.FOOTER:
            {
                return new UltimateRecyclerviewViewHolder(view);
            }
            default:
                break;
        }

        return null;
    }

    @Override
    protected void bindCustomViewHolder(final KDBaseViewHolder holder, final int position, final int viewTypes) {
        switch (viewTypes)
        {
            case VIEW_TYPES.NORMAL:
            {
                String model = mDataList.get(position);
                holder.showData(position, model);
            }
            break;
            case VIEW_TYPES.HEADER:
            {
                holder.showData(position, null);
            }
            break;
            case VIEW_TYPES.FOOTER:
            {
                break;
            }
            default:
                break;
        }
    }

    @Override
    protected @LayoutRes int getItemLayoutResId() {
        return R.layout.layout_recycler_view_item;
    }
}
